package org.gorson.function;

import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.streaming.api.functions.ProcessFunction;
import org.apache.flink.util.Collector;
import org.gorson.BO.SensorReadingBO;

public class ProcessTransformSensorTimestampToStringFunction extends ProcessFunction<SensorReadingBO, Tuple3<String, String, Double>> {
    @Override
    public void processElement(SensorReadingBO sensorReadingBO, Context context, Collector<Tuple3<String, String, Double>> collector) throws Exception {
        Tuple3<String, String, Double> tuple3 = new Tuple3<>();
        tuple3.setField(sensorReadingBO.id,0);
        tuple3.setField(String.format("%tF %<tT",sensorReadingBO.timestamp),1);
        tuple3.setField(sensorReadingBO.temperature, 2);
        collector.collect(tuple3);
    }
}
